package cn.mrlong.keeplive.keeplive;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by BINGO on 2018/11/28.
 */

public class SPUtils {

    private static void throwInit(Context mContext) {
        if (mContext == null) {
            throw new NullPointerException("SPUtils====>初始化没有Context");
        }
    }

    public static boolean putBoolean(Context mContext, String fileName, String key, boolean value) {
        throwInit(mContext);
        SharedPreferences sp = mContext.getSharedPreferences(fileName, Context.MODE_PRIVATE);
        return sp.edit().putBoolean(key, value).commit();
    }

    public static boolean getBoolean(Context mContext, String fileName, String key, boolean defaultValue) {
        throwInit(mContext);
        SharedPreferences sp = mContext.getSharedPreferences(fileName, Context.MODE_PRIVATE);
        return sp.getBoolean(key, defaultValue);
    }
}
